package com.andova.component;

import android.widget.ImageView;

import com.andova.component.log.AndovaLogComponent;
import com.andova.component.pic.AndovaPicComponent;
import com.andova.component.pic.IPicDisplayOption;

import androidx.annotation.DrawableRes;
import androidx.appcompat.app.AppCompatActivity;

/**
 * Created by Administrator on 2018-08-23.
 *
 * @author kzaxil
 * @since 0.0.2
 */
public class AndovaComponentAppCompatActivity extends AppCompatActivity {
    protected final void displayImage(Object attachTarget, String url, ImageView imageView) {
        AndovaPicComponent component = AndovaComponentManager.getInstance().picComponent();
        if (component == null) return;
        component.picDisplay().displayImage(attachTarget, url, imageView);
    }

    protected final void displayImage(Object attachTarget, String url, ImageView imageView, @DrawableRes int placeholder, @DrawableRes int error) {
        AndovaPicComponent component = AndovaComponentManager.getInstance().picComponent();
        if (component == null) return;
        component.picDisplay().displayImage(attachTarget, url, imageView, placeholder, error);
    }

    protected final void displayImage(Object attachTarget, Object url, IPicDisplayOption option) {
        AndovaPicComponent component = AndovaComponentManager.getInstance().picComponent();
        if (component == null) return;
        component.picDisplay().displayImage(attachTarget, url, option);
    }

    protected final void i(Object msg) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.i(msg);
    }

    protected final void i(Object msg, Throwable t) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.i(msg, t);
    }

    protected final void d(Object msg) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.d(msg);
    }

    protected final void d(Object msg, Throwable t) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.d(msg, t);
    }

    protected final void w(Object msg) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.w(msg);
    }

    protected final void w(Object msg, Throwable t) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.w(msg, t);
    }

    protected final void e(Object msg) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.e(msg);
    }

    protected final void e(Object msg, Throwable t) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.e(msg, t);
    }

    protected final void t(Object msg) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.t(msg);
    }

    protected final void t(Object msg, Throwable t) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.t(msg, t);
    }

    protected final void v(Object msg) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.v(msg);
    }

    protected final void v(Object msg, Throwable t) {
        AndovaLogComponent component = AndovaComponentManager.getInstance().logComponent();
        if (component == null) return;
        component.v(msg, t);
    }
}
